@echo off

REM SHA1 sums of files required
REM da979604f7a2aa8b5a6d4a5debd2e80f77569e35 decoder.2
REM d19036cbc46b130548873597b44b8b70758f25c4 decoder.3
REM a57f5278ffe44248fc73f9925d107f4024ad981a defend.1
REM a9481478da38f99efb67f0ecf82d084e14b93b42 defend.2
REM a24cfc55de56a72758c76fe2a55f1ec6c353b16f defend.3
REM ed6ce796702ff32209ced3cb1ba3837dbafa526f defend.4
REM a960fd1559ed74b81deba434391e49fc6ec389ca defend.6
REM 2f89951dbe55d80df43df8dcf497171f73e726d3 defend.7
REM 9d7bc3c89e5a53c575946f06702c722b864b1ff0 defend.8
REM 67ccc194b1753a18af0c85f5e603355549c4f727 defend.9
REM 9292b94b0d74e57e03aada4852ad1997c34122ff defend.10
REM 59b018ba0f3fe6eadfd387dc180ac281460358bc defend.11
REM 26e48dfeefa0766837b1e762695b9532dbc8bc5e defend.12
REM ceb0d18483f0691978c604db94417e6941ad7ff2 defend.snd

set rom_path_src=..\roms\defender
set rom_path_dst=..\build
set romgen_path=..\tools

mkdir %rom_path_dst%
REM generate RAMB structures for larger ROMS

REM combine smaller ROMs into bigger ones
copy/b %rom_path_src%\defend.snd + %rom_path_src%\defend.snd  %rom_path_dst%\temp.snd
copy/b %rom_path_src%\defend.1 + %rom_path_src%\defend.4  %rom_path_dst%\temp.a
copy/b %rom_path_src%\defend.9 + %rom_path_src%\defend.12 %rom_path_dst%\temp.1
copy/b %rom_path_src%\defend.8 + %rom_path_src%\defend.11 %rom_path_dst%\temp.2
copy/b %rom_path_src%\defend.7 + %rom_path_src%\defend.10 %rom_path_dst%\temp.3
copy/b %rom_path_src%\defend.6 + %rom_path_src%\defend.6  %rom_path_dst%\temp.4

REM soundcpu
%romgen_path%\romgen %rom_path_dst%\temp.snd     SND_ROM_0F    12 l r e > %rom_path_dst%\SND_ROM_0F.vhd

REM decoders
%romgen_path%\romgen %rom_path_src%\decoder.2    DECODER_4      9 a     > %rom_path_dst%\DEC_4.vhd
%romgen_path%\romgen %rom_path_src%\decoder.3    DECODER_6      9 a     > %rom_path_dst%\DEC_6.vhd

REM maincpu
%romgen_path%\romgen %rom_path_dst%\temp.a       CPU_ROM_0D    12 l r e > %rom_path_dst%\CPU_ROM_0D.vhd
%romgen_path%\romgen %rom_path_src%\defend.2     CPU_ROM_0E    12 l r e > %rom_path_dst%\CPU_ROM_0E.vhd
%romgen_path%\romgen %rom_path_src%\defend.3     CPU_ROM_0F    12 l r e > %rom_path_dst%\CPU_ROM_0F.vhd
%romgen_path%\romgen %rom_path_dst%\temp.1       CPU_ROM_10    12 l r e > %rom_path_dst%\CPU_ROM_10.vhd
%romgen_path%\romgen %rom_path_dst%\temp.2       CPU_ROM_11    12 l r e > %rom_path_dst%\CPU_ROM_11.vhd
%romgen_path%\romgen %rom_path_dst%\temp.3       CPU_ROM_12    12 l r e > %rom_path_dst%\CPU_ROM_12.vhd

REM fill in dummy ROMs, only top half of 16 is needed
%romgen_path%\romgen %rom_path_dst%\temp.4       CPU_ROM_13    12 l r e > %rom_path_dst%\CPU_ROM_13.vhd
%romgen_path%\romgen %rom_path_dst%\temp.4       CPU_ROM_14    12 l r e > %rom_path_dst%\CPU_ROM_14.vhd
%romgen_path%\romgen %rom_path_dst%\temp.4       CPU_ROM_15    12 l r e > %rom_path_dst%\CPU_ROM_15.vhd
%romgen_path%\romgen %rom_path_dst%\temp.4       CPU_ROM_16    12 l r e > %rom_path_dst%\CPU_ROM_16.vhd
%romgen_path%\romgen %rom_path_dst%\temp.4       CPU_ROM_17    12 l r e > %rom_path_dst%\CPU_ROM_17.vhd
%romgen_path%\romgen %rom_path_dst%\temp.4       CPU_ROM_18    12 l r e > %rom_path_dst%\CPU_ROM_18.vhd

echo done
pause
